package cn.itsource.feign.fallback;

/**
 * @description: 降级类
 * @Author: Jason
 * @Date: 2022/9/4 18:51
 */

import cn.itsource.doc.CourseDoc;
import cn.itsource.feign.client.CourseFeignClient;
import cn.itsource.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class CourseFeignClientFallback implements FallbackFactory<CourseFeignClient> {

    @Override
    public CourseFeignClient create(Throwable throwable) {
        return new CourseFeignClient(){
            @Override
            public JSONResult saveCourse(List<CourseDoc> doc) {
                throwable.printStackTrace();
                return JSONResult.error("课程上线保存ES失败");
            }
        };
    }
}